package com.atguigu.java;

public class homework2 {
		public static void main(String[] args) {
				
				student[] s1 = new student[20];
				
				for(int i = 0; i < s1.length;i++){
						//给数组元素赋值
						s1[i] = new student();
						//给student对象的属性赋值
						s1[i].number = i +1;
						//年级：[1,6]
						s1[i].state = (int)(Math.random() *(6-1+1)+1);
						//成绩：[0,100]
						s1[i].score = (int)(Math.random()*(100-0+1));
				}
				
				//遍历学生数组
				for(int i = 0 ; i < s1.length; i++){
						System.out.println(s1[i].info());
				}
				
				System.out.println("********************************");
				
				for(int i = 0 ; i < s1.length; i++){
					if (s1[i].state == 3){
						System.out.println(s1[i].info());
					}
			    }
			
				System.out.println("********************************");
				
				
				 
		}	
}


class student{
		
		//属性
		int number;//学号
		int state;//年级
		int score;//成绩
		
		
		public String info(){
				return "学号：" + number + "，年级：" + state + "，分数：" + score;
		}
		
		
	
}